package com.heima.user.controller.v1;

import com.heima.common.constants.user.UserConstants;
import com.heima.model.common.dtos.PageRequestDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.user.service.ApUserRealnameService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 胡慧
 * @title: ApUserRealnameController
 * @projectName heima-leadnews
 * @description: TODO
 * @date 2021/2/2021:47
 */
@RestController
@Slf4j
@RequestMapping("/api/v1/auth")
public class ApUserRealnameController {
    @Autowired
    private ApUserRealnameService apUserRealnameService;
    @PostMapping("/list")
    public ResponseResult loadListByStatus(@RequestBody AuthDto authDto){
        return apUserRealnameService.loadListByStatus(authDto);
    }
    //审核通过
    @GlobalTransactional
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto) {

        return apUserRealnameService.updateStatusById(dto, UserConstants.PASS_AUTH);
    }
    //审核不通过
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        return apUserRealnameService.updateStatusById(dto, UserConstants.FAIL_AUTH);
    }
}
